package com.wei.frame.di.module;

import android.app.Application;
import android.content.Context;

import androidx.annotation.Nullable;

import com.google.gson.Gson;
import com.wei.frame.integration.IRepositoryManager;
import com.wei.frame.integration.RepositoryManager;
import com.wei.frame.net.RetrofitManager;
import com.wei.frame.utils.AppManager;

import javax.inject.Singleton;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import retrofit2.Retrofit;

/**
 * 作者：赵若位
 * 时间：2020/8/20 3:10
 * 邮箱：1070138445@qq.com
 * 功能：
 */
@Module
public abstract class AppModule {
    @Singleton
    @Provides
    public static Context provideContext(@Nullable Application application) {
        return application.getApplicationContext();
    }

    @Singleton
    @Provides
    public static Gson providerGson() {
        return new Gson();
    }


    @Singleton
    @Provides
    public static AppManager providerAppManager() {
        return AppManager.getInstance();
    }

    @Singleton
    @Provides
    public static Retrofit providerRetrofit() {
        return RetrofitManager.getInstance().getRetrofit();
    }

//    @Singleton
//    @Provides
//    public static Retrofit providerRetrofit(String url) {
//
//    }

    @Binds
    abstract IRepositoryManager bindRepositoryManager(RepositoryManager manager);


}
